import * as echarts from "echarts"; //引入echarts 插件


export function bar(params) {
    var mychart = echarts.init(document.getElementById(params.dom))
    var option = {
        grid: {
            left: "10%",
            right: "10%",
            height: "70%",
            bottom:"15%"
        },
        tooltip: {
            show: true,
            formatter: function (params) {
                console.log("params：", params.seriesName)
                //$.get("params.seriesName")
            },
            axisPointer: {
                type: "cross"
            }
        },
        color: ["blue", "red"],
        xAxis: {
            type: "category",
            axisTick: {
                show: false
            },
            data: [2016, 2017, 2018, 2019, 2020]
        },
        yAxis: {
            type: "value",
            name: "(万人)",
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            interval: 100
        },
        series: [
            {
                name: "职业资格证书获取情况",
                type: "bar",
                data:params.ydata1 ,
                stack: "A",
            },
        ]
    }
    if (params.angle=="round") {          
        option.series[0].itemStyle={
            barBorderRadius: [5, 5, 0, 0]
        }
    }
    mychart.setOption(option)
}

export function bar1(params) {
    var mychart = echarts.init(document.getElementById(params.dom))
    var option = {
        grid: {
            left: "15%",
            bottom:"12%"
        },
        legend: {
            show: true,
            itemWidth:10,
            textStyle: {
                color: "white",
                fontSize:9,
            },
            icon: "square"

        },
        tooltip: {
            show: true,
            formatter: function (params) {
                console.log("params：", params.seriesName)
                //$.get("params.seriesName")
            },
            axisPointer: {
                type: "cross"
            }
        },
        color: params.color,
        xAxis: {
            type: "category",
            axisLabel: {
                fontSize:8

            },
            axisTick: {
                show: false
            },
            data: [2016, 2017, 2018, 2019, 2020]
        },
        yAxis: {
            type: "value",
            name: params.yAxisName,
            nameTextStyle: {
                color: "aqua",
                fontSize:8
            },
            axisLabel: {
                fontSize: 8,
                
            },
            axisLine: {
                show: false
            },
            axisTick: {
                show: false,
                
            },
            splitNumber:3       
            
        },
        series: [
            {
                name: params.name1,
                type: "bar",
                data: params.yData1,
                stack: "A",
                barWidth:10
            },
            {
                name: params.name2,
                type: "bar",
                data: params.yData2,
                stack: "A",
                barWidth: 10,
                itemStyle: {
                    barBorderRadius: [3, 3, 0, 0]
                }
            },
        ]
    }
    mychart.setOption(option)
}

export function mid(params) {
    var mychart = echarts.init(document.getElementById(params.dom))
    var option = {
        title: {
            text: 'Basic Radar Chart'
          },
          legend: {
            data: ['Allocated Budget', 'Actual Spending']
          },
          radar: {
            // shape: 'circle',
            indicator: [
              { name: 'Sales', max: 6500 },
              { name: 'Administration', max: 16000 },
              { name: 'Information Technology', max: 30000 },
              { name: 'Customer Support', max: 38000 },
              { name: 'Development', max: 52000 },
              { name: 'Marketing', max: 25000 }
            ]
          },
          series: [
            {
              name: 'Budget vs spending',
              type: 'radar',
              data: [
                {
                  value: [4200, 3000, 20000, 35000, 50000, 18000],
                  name: 'Allocated Budget'
                },
                {
                  value: [5000, 14000, 28000, 26000, 42000, 21000],
                  name: 'Actual Spending'
                }
              ]
            }
          ]
    }
    mychart.setOption(option)
}

export function left_up(params) {
    var mychart = echarts.init(document.getElementById(params.dom))
    var option = {
        xAxis: {
            type: 'category',
            data: ['20计算机1班', '20计算机2班', '20计算机3班',]
          },
          yAxis: {
            type: 'value'
          },
          series: [
            {
            //   data:data.  
              data: params.ydata1,
              type: 'line'
            }
          ]
    }
    mychart.setOption(option)
}

export function left_dowm(params) { 
    var mychart = echarts.init(document.getElementById(params.dom))
    var option = {
        title: {
            text: 'Referer of a Website',
            subtext: 'Fake Data',
            left: 'center'
          },
          tooltip: {
            trigger: 'item'
          },
          legend: {
            orient: 'vertical',
            left: 'left'
          },
          series: [
            {
              name: 'Access From',
              type: 'pie',
              radius: '50%',
              data: [
                { value: 1048, name: 'Search Engine' },
                { value: 735, name: 'Direct' },
                { value: 580, name: 'Email' },
                { value: 484, name: 'Union Ads' },
                { value: 300, name: 'Video Ads' }
              ],
              emphasis: {
                itemStyle: {
                  shadowBlur: 10,
                  shadowOffsetX: 0,
                  shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
              }
            }
          ]
    }
    mychart.setOption(option)
 }

export function right_up(params) { 
    var mychart = echarts.init(document.getElementById(params.dom))
    var option = {
        xAxis: {},
        yAxis: {},
        series: [
          {
            symbolSize: 20,
            data: [
              [10.0, 8.04],
              [8.07, 6.95],
              [13.0, 7.58],
              [9.05, 8.81],
              [11.0, 8.33],
              [14.0, 7.66],
              [13.4, 6.81],
              [10.0, 6.33],
              [14.0, 8.96],
              [12.5, 6.82],
              [9.15, 7.2],
              [11.5, 7.2],
              [3.03, 4.23],
              [12.2, 7.83],
              [2.02, 4.47],
              [1.05, 3.33],
              [4.05, 4.96],
              [6.03, 7.24],
              [12.0, 6.26],
              [12.0, 8.84],
              [7.08, 5.82],
              [5.02, 5.68]
            ],
            type: 'scatter'
          }
        ]
    }
    mychart.setOption(option)
}

export function right_down(params) { 
    var mychart = echarts.init(document.getElementById(params.dom))
    var option = {
        title: {
            text: 'Funnel'
          },
          tooltip: {
            trigger: 'item',
            formatter: '{a} <br/>{b} : {c}%'
          },
          toolbox: {
            feature: {
              dataView: { readOnly: false },
              restore: {},
              saveAsImage: {}
            }
          },
          legend: {
            data: ['Show', 'Click', 'Visit', 'Inquiry', 'Order']
          },
          series: [
            {
              name: 'Funnel',
              type: 'funnel',
              left: '10%',
              top: 60,
              bottom: 60,
              width: '80%',
              min: 0,
              max: 100,
              minSize: '0%',
              maxSize: '100%',
              sort: 'descending',
              gap: 2,
              label: {
                show: true,
                position: 'inside'
              },
              labelLine: {
                length: 10,
                lineStyle: {
                  width: 1,
                  type: 'solid'
                }
              },
              itemStyle: {
                borderColor: '#fff',
                borderWidth: 1
              },
              emphasis: {
                label: {
                  fontSize: 20
                }
              },
              data: [
                { value: 60, name: 'Visit' },
                { value: 40, name: 'Inquiry' },
                { value: 20, name: 'Order' },
                { value: 80, name: 'Click' },
                { value: 100, name: 'Show' }
              ]
            }
          ]
    }
    mychart.setOption(option)
}


